<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=Edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="format-detection" content="telephone=yes">

    <meta content="telephone=yes,email=yes" name="format-detection">
    <!--//自动识别电话号码和邮箱-->

    <meta content="yes" name="apple-mobile-web-app-capable">
    <!--//苹果手机：会删除默认的工具栏和菜单栏，网站开启对web app程序的支持-->
    <meta name="apple-mobile-web-app-status-bar-style" content="default"/>
    <!--//苹果手机：在web app应用下状态条（屏幕顶部条）的颜色,默认值为default（白色），可以定为black（黑色）和black-translucent（灰色半透明）。-->
    <meta name="apple-touch-fullscreen" content="yes"/>
    <!--//苹果手机：如果把一个web app添加到了主屏幕中，那么从主屏幕中打开这个web app则全屏显示-->
    <link rel="apple-touch-icon" href="images/HTML5_Badge_64.png"/>
    <!--//苹果手机：将应用添加到手机主屏幕，会有一个icon可以直接进入-->
    <title>有收入</title>
    <meta name="description" content="">
    <meta name="keywords" content="">
    <!--初始化样式-->
    <link rel="stylesheet" href="css/reset.css">
    <!--共用样式-->
    <link rel="stylesheet" href="css/common.css">
    <!--整个网站的局部样式-->
    <link rel="stylesheet" href="css/style.css">
    <!--适配样式-->
    <link rel="stylesheet" href="css/styleMedia.css">
    <style>
        html, body {
            position: relative;
            overflow-x: hidden;
        }
    </style>
</head>
<body style="background-color: #f4f9fd;">

<!--header begin-->
<header>
    <div id="flexHeader">
        <div class="div1 mui-action-back"><a><img src="images/icon_arrow_left.png"></a> </div>
        <div class="div2">申诉中心</div>
        <div class="div3"></div>
    </div>
</header>
<!--header end-->

<!--tab begin-->
<article class="tab">
    <div class="wang-tab">
        <div class="wang-tab-head">
            <span class="wang-tab-head-title  wang-tab-head-title-2-47  wang-tab-title-transition addSelected  wang-tab-head-title-active" id='wang-tab-head-title-1'>我收到的申诉</span>
            <span class="wang-tab-head-title  wang-tab-head-title-2-47  wang-tab-title-transition" id='wang-tab-head-title-2' >我发起的申诉</span>
        </div>
        <div class="content-incomplete-tasks">
            <div id="appeals1List" class="wang-tab-content wang-tab-content-1 transition">
                <div class="to-be-operated">
                    <div>
                        <img src="images/img_taobao.png">
                        <p>任务编号</p>
                        <time>2018-09-29&nbsp;11:58:00</time>
                    </div>
                    <div onclick="pageJump(this)" name="receivedComplaint">
                        <img src="images/img_shopping_1.png">
                        <div class="content-money">
                            <p class="type-of-complaint">投诉类型:<span>资金问题</span></p>
                            <p>申诉内容：<span>为什么不给我返款</span></p>
                        </div>
                        <a href="#" class="to-be-operated-show">处理中</a>
                    </div>
                </div>
                <div class="to-be-operated">
                    <div>
                        <img src="images/img_taobao.png">
                        <p>任务编号</p>
                        <time>2018-09-29&nbsp;11:58:00</time>
                    </div>
                    <div  onclick="pageJump(this)" name="receivedComplaint">
                        <img src="images/img_shopping_1.png">
                        <div class="content-money">
                            <p class="type-of-complaint">投诉类型:<span>资金问题</span></p>
                            <p>申诉内容：<span>为什么不给我返款</span></p>
                        </div>
                        <a href="#" class="to-be-operated-show">已完结</a>
                    </div>
                </div>

            </div>
            <div id="appeals0List" class="wang-tab-content wang-tab-content-2 transition">
                <div class="to-be-operated">
                    <div>
                        <img src="images/img_taobao.png">
                        <p>任务编号</p>
                        <time>2018-09-29&nbsp;11:58:00</time>
                    </div>
                    <div onclick="pageJump(this)" name="appealTask">
                        <img src="images/img_shopping_1.png">
                        <div class="content-money">
                            <p class="type-of-complaint">投诉类型:<span>资金问题</span></p>
                            <p>申诉内容：<span>为什么不给我返款</span></p>
                        </div>
                        <a href="#" class="to-be-operated-show">处理中</a>
                    </div>
                </div>
                <div class="to-be-operated">
                    <div>
                        <img src="images/img_taobao.png">
                        <p>任务编号</p>
                        <time>2018-09-29&nbsp;11:58:00</time>
                    </div>
                    <div onclick="pageJump(this)" name="appealTask">
                        <img src="images/img_shopping_1.png">
                        <div class="content-money">
                            <p class="type-of-complaint">投诉类型:<span>资金问题</span></p>
                            <p>申诉内容：<span>为什么不给我返款</span></p>
                        </div>
                        <a href="#" class="to-be-operated-show">已完结</a>
                    </div>
                </div>
            </div>
        </div>
    </div>
</article>

<!--tab end-->


<!--js-->
<script src="js/jquery-1.12.3.min.js"></script>
<script src="js/common.js"></script>
<script src="js/mui.min.js"></script>
<script src="js/vconsole.min.js"></script>
<script src="js/config.js"></script>
<script>
	var v = new VConsole()
	function goto(id){
		this.location = 'receivedComplaint.html?id=' + id
	}
	
	$(function () {
		var user = JSON.parse(localStorage.getItem('user'))
		$.ajax({
			url: $CONFIG.baseUrl + "/api/appeal?appUserId=" + user.id,
			type: 'get',
			contentType:false,
			processData:false,
			beforeSend:function(x){
				x.setRequestHeader("Authorization", localStorage.getItem('token'));
			},
			success: function(data){
				console.log(JSON.stringify(data))
				if (data.code == 200) {
					if (data.data.appeals1) {
						showAppeals(data.data.appeals1, 1)
					}
					if (data.data.appeals0) {
						showAppeals(data.data.appeals0, 0)
					}
				}
				
			},
			error: function(error){
				console.log('error')
				loadingClose()
			}
		})
	})
	
	function showAppeals(list, type) {
		if (list.length > 0) {
			var n = '<div onclick="goto(#7)" class="to-be-operated">\
                    <div>\
                        <img src="images/img_taobao.png">\
                        <p>#1</p>\
                        <time>#2</time>\
                    </div>\
                    <div onclick="pageJump(this)" name="receivedComplaint">\
                        <img src="http://tbk.tutew.com/#3">\
                        <div class="content-money">\
                            <p class="type-of-complaint">投诉类型:<span>#4</span></p>\
                            <p>申诉内容：<span>#5</span></p>\
                        </div>\
                        <a href="#" class="to-be-operated-show">#6</a>\
                    </div>\
                </div>'
            var result = ''
			for (i = 0; i < list.length; i++) {
				result += n.replace("#1", list[i].orderId)
							.replace("#2", list[i].ct)
							.replace("#3", list[i].pic1)
							.replace("#4", list[i].type == 0 ? "资金问题" : "其它问题")
							.replace("#5", list[i].content)
							.replace("#6", function () {
								var x = ''
								switch (list[i].status){
									case 0:
									  x = "处理中";
									  break;
									case 1:
									  x = "已完结";
									  break;
									case 1:
									  x = "申诉驳回";
									  break;
								}
								return x
							}).replace("#7", list[i].id)
			}
			if (type == 1) {
				$('#appeals1List').html(result);
			} else {
				$('#appeals0List').html(result);
			}
			
		}
	}
	
</script>
</body>
</html>